Repository navigation
feat: keep the architecture file format when marking the root as existing - #154
Open
Git-PrinceNagar wants to merge 2 commits into
Open
Git-PrinceNagar wants to merge 2 commits into
Git-PrinceNagar wants to merge 2 commits into
Conversation
added 2 commits
November 26, 2026 11:34
…ting The bootstrap decoded the starter architecture file and wrote it back with yamlencode or jsonencode to set exists = true on the intermediate root management group. That sorted and quoted every key, dropped comments and blank lines, and minified JSON files. The file is now written as authored when its root already has exists: true, or with only the first exists: false changed to true. Either text is used only when it decodes to the same content as before; otherwise the previous re-encoded output is kept (root not first, root without an exists key). Refs Azure/Azure-Landing-Zones#4069
A comment that mentions "exists: false" before the root management group made the single first-match pattern hit the comment, so the guard fell back to re-encoding the whole file. Try a line-anchored key match first, then the previous pattern for flow mappings and minified JSON. Refs Azure/Azure-Landing-Zones#4069
Git-PrinceNagar
requested a deployment
to
CSUTF
December 2, 2026 05:14 — with
GitHub Actions
Waiting
Git-PrinceNagar
requested a deployment
to
CSUTF
December 2, 2026 05:14 — with
GitHub Actions
Waiting
Git-PrinceNagar
requested a deployment
to
CSUTF
December 2, 2026 05:14 — with
GitHub Actions
Waiting
Git-PrinceNagar
requested a deployment
to
CSUTF
December 2, 2026 05:14 — with
GitHub Actions
Waiting
Git-PrinceNagar
requested a deployment
to
CSUTF
December 2, 2026 05:14 — with
GitHub Actions
Waiting
Git-PrinceNagar
requested a deployment
to
CSUTF
December 2, 2026 05:14 — with
GitHub Actions
Waiting
Git-PrinceNagar
requested a deployment
to
CSUTF
December 2, 2026 05:14 — with
GitHub Actions
Waiting
Git-PrinceNagar
requested a deployment
to
CSUTF
December 2, 2026 05:14 — with
GitHub Actions
Waiting
Git-PrinceNagar
requested a deployment
to
CSUTF
December 2, 2026 05:14 — with
GitHub Actions
Waiting
Git-PrinceNagar
requested a deployment
to
CSUTF
December 2, 2026 05:14 — with
GitHub Actions
Waiting
Git-PrinceNagar
requested a deployment
to
CSUTF
December 2, 2026 05:14 — with
GitHub Actions
Waiting
Git-PrinceNagar
requested a deployment
to
CSUTF
December 2, 2026 05:14 — with
GitHub Actions
Waiting
Git-PrinceNagar
requested a deployment
to
CSUTF
December 2, 2026 05:14 — with
GitHub Actions
Waiting
Git-PrinceNagar
requested a deployment
to
CSUTF
December 2, 2026 05:14 — with
GitHub Actions
Waiting
Git-PrinceNagar
requested a deployment
to
CSUTF
December 2, 2026 05:14 — with
GitHub Actions
Waiting
Git-PrinceNagar
requested a deployment
to
CSUTF
December 2, 2026 05:14 — with
GitHub Actions
Waiting
Git-PrinceNagar
requested a deployment
to
CSUTF
December 2, 2026 05:14 — with
GitHub Actions
Waiting
Git-PrinceNagar
requested a deployment
to
CSUTF
December 2, 2026 05:14 — with
GitHub Actions
Waiting
Git-PrinceNagar
requested a deployment
to
CSUTF
December 2, 2026 05:14 — with
GitHub Actions
Waiting
Git-PrinceNagar
requested a deployment
to
CSUTF
December 2, 2026 05:14 — with
GitHub Actions
Waiting
Git-PrinceNagar
requested a deployment
to
CSUTF
December 2, 2026 05:14 — with
GitHub Actions
Waiting
Git-PrinceNagar
requested a deployment
to
CSUTF
December 2, 2026 05:14 — with
GitHub Actions
Waiting
Git-PrinceNagar
requested a deployment
to
CSUTF
December 2, 2026 05:14 — with
GitHub Actions
Waiting
Git-PrinceNagar
requested a deployment
to
CSUTF
December 2, 2026 05:14 — with
GitHub Actions
Waiting
Git-PrinceNagar
requested a deployment
to
CSUTF
December 2, 2026 05:14 — with
GitHub Actions
Waiting
Git-PrinceNagar
requested a deployment
to
CSUTF
December 2, 2026 05:14 — with
GitHub Actions
Waiting
Git-PrinceNagar
requested a deployment
to
CSUTF
December 2, 2026 05:14 — with
GitHub Actions
Waiting
Git-PrinceNagar
requested a deployment
to
CSUTF
December 2, 2026 05:14 — with
GitHub Actions
Waiting
This branch is waiting to be deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview/Summary
The bootstrap now writes the starter's Terraform architecture file as authored and changes only the intermediate root management group's
exists: falsetotrue. Before, every Terraform run re-encoded the whole file withyamlencodeorjsonencode, which quoted and sorted every key, dropped comments and blank lines, and minified JSON.Refs Azure/Azure-Landing-Zones#4069
This PR fixes/adds/changes/removes
modules/file_manipulation/locals.intermediate_root_management_group.tftries the original text first, then the original with the firstexists: falseset totrue. It writes the first text that decodes to the same content the module produced before. If none does, it writes the previousyamlencodeorjsonencodeoutput.exists: trueis written byte for byte.alz/github,alz/azuredevopsandalz/localall call the same module.Breaking Changes
Testing Evidence
Unit tests with
terraform teston Terraform 1.17.2, with no providers and no Azure deployment. A harness callsmodules/file_manipulationthe wayalz/localdoes and compares the generated architecture file with a hand-written expected file.Before, on main
c58ce10, with the test starter template from alz-terraform-accelerator:After, the file as authored with only the root line changed:
Results on this branch:
On main
c58ce10, 7 of the 9 runs fail. With the decoded-content comparison removed, three runs fail, so that comparison keeps the fallback cases correct. Thirteen more edge cases pass, including"exists"and'exists'keys,---document markers, flow mappings, YAML merge keys, minified JSON,.ymland a root last with no trailing newline.These inputs still get the previous re-encoded output, with correct content and the old layout. The root is not first in
management_groups, the root has noexistskey, the value isexists: False, or a block scalar containingexists: falsecomes before the root.terraform fmt -check -recursiveis clean andterraform validatepasses onalz/local,alz/githubandalz/azuredevops. TFLint reports the same findings as main.I also ran
Deploy-Accelerator(ALZ PowerShell module 7.1.5,alz_local,platform_landing_zonestarter) in a test tenant. On main, the saved bootstrap plan writes the re-encoded file. On this branch, the bootstrap applied, the generated architecture file matched the authored file except for the rootexistsflag, and a second plan returnedNo changes. I then deployed the full hub-and-spoke platform in centralindia from the generated files. The bootstrap created 164 resources, the platform created 1213, and a second platform plan returnedNo changes. The management-only, migration and SLZ variants of the example applied and re-planned the same way.As part of this Pull Request I have
modules/file_manipulation.mainbranchc58ce10.mainhas one newer commit,0a3cc0d, which changes only a workflow file.